package com.neusoft.neuiotms.dcvm.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import com.neusoft.bizcore.web.jpa.model.AbstractModel;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "dcvm_model")
public class Model extends AbstractModel {
    private static final long serialVersionUID = 1L;

    /** 模具名 */
    @NotNull(message = "模具名不能为空")
    @Column(length = 255, nullable = false)
    private String modelName;

    /** 模具编码 */
    @NotNull(message = "模具编码不能为空")
    @Column(length = 255, nullable = false, unique = true)
    private String modelCode;

    /** 模具类别 */
    @NotNull(message = "模具类别不能为空")
    private String typeId;

    /** 长度 */
    private Integer length = 0;
    /** 宽度 */
    private Integer width = 0;
    /** 高度 */
    private Integer height = 0;
    /** 预览图存储ID */
    @Column(length = 255, nullable = true)
    private String previewFsId = "";
    /** 小地图存储ID */
    @Column(length = 255, nullable = true)
    private String mapFsId = "";

    /** 模具版本 */
    // 声明mappedBy，说明一方放弃维护关系
    @OneToMany(mappedBy = "model", fetch = FetchType.EAGER)
    @Cascade({CascadeType.ALL })
    private List<ModelVersion> versionList = new ArrayList<>();

}
